The blockchain technology is also referred to as a distributed ledger technology. As a distributed Internet database technology, the blockchain technology is characterized by decentralization, transparency, non-tampering, and trustworthiness. A network constructed based on the blockchain technology can be referred to as a blockchain network. The blockchain network includes network nodes (which can also be referred to as a blockchain node, and is simply referred to as a node below). Each network node corresponds to at least one blockchain, and each blockchain includes at least one block.
When receiving data to be stored, the network node broadcasts the data to be stored to other network nodes in the blockchain network. Therefore, each network node in the blockchain network stores full data of the blockchain network, and data stored on one network node is consistent with that stored on another node.
Data is generally stored in the blockchain network in two stages: In a first stage, a node in the blockchain network receives data to be stored, and broadcasts the data all over the blockchain network. As such, each node in the blockchain network receives the data to be stored. In this case, each network node in the blockchain network writes the data to be stored in a cache. In a second stage, a network node in the blockchain network that obtains permission to store the data to be stored writes the data to be stored in a block when obtaining recording permission, and adds the block to an existing blockchain. It can be seen that the data is stored in the blockchain network by using an asynchronous writing policy.
However, in an actual service scenario, when service data is stored in a blockchain network by using an asynchronous writing policy, generally, a data pool queue is maintained in a first stage, and data to be stored is sequentially written into the data pool queue based on a timestamp of the data to be stored. As such, in a second stage, data to be stored in the data pool queue is written into a block based on a first in first out principle.
According to certain researches, in the previous method, there are the following problems in storing data in the blockchain network: For services with relatively high service priorities, service data processing efficiency is relatively low, and consequently processing efficiency of these services is relatively low.